﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    //protected int id, foodType, location;
    //protected float weight;

    protected Container container;


    protected void Page_Load(object sender, EventArgs e)
    {
        //id = int.Parse(Request.QueryString["id"]);
        //foodType = int.Parse(Request.QueryString["type"]);
        //location = int.Parse(Request.QueryString["location"]);
        //weight = float.Parse(Request.QueryString["weight"]);

        //lblID.Text = id.ToString();
        //lblLocation.Text = location.ToString();
        //lblType.Text = foodType.ToString();
        //lblWeight.Text = weight.ToString();

        container =  (Container)Session["Container"];

        if (container == null)
        {
            Response.Redirect("default.aspx");
        }

        lblID.Text = container.BinNumber.ToString();
        //lblID.Text = container.ContainerID.ToString();
        lblWeight.Text = container.Weight.ToString();

        using (CCSEntities db = new CCSEntities())
        {
            lblLocation.Text = (from l in db.Locations
                                where l.LocationID == container.LocationID
                                select l).First().RoomName;

            lblType.Text = (from t in db.FoodCategories
                            where t.FoodCategoryID == container.FoodCategoryID
                            select t).First().CategoryType;

        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (CCSEntities db = new CCSEntities())
        {
           Container cont = (from c in db.Containers
                         where c.ContainerID == container.ContainerID
                         select c).FirstOrDefault();

           cont.Weight = container.Weight;
           cont.LocationID = container.LocationID;
           cont.FoodCategoryID = container.FoodCategoryID;

            db.SaveChanges();
        }
       // Response.Redirect("default");
        Response.Redirect("default.aspx");

    }

}